#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct node {
    int val;
    int pos;
};

node nodes[100005];

vector<int> twoSum(vector<int>& numbers, int target) {
    for (int i = 0; i < numbers.size(); i++) {
        nodes[i].val = numbers[i];
        nodes[i].pos = i+1;
    }
    sort(nodes, nodes + numbers.size(),
         [](node a, node b) { return a.val < b.val; });
    int left = 0;
    int right = numbers.size() - 1;
    while (left < right) {
        if (nodes[left].val + nodes[right].val == target)
            return vector<int>{nodes[left].pos, nodes[right].pos};
        while(nodes[left].val + nodes[right].val < target) left++;
        while(nodes[left].val + nodes[right].val > target) right--;
    }
    return vector<int> {-1,-1};
}

int main(){
    vector<int> nums{3,2,4};
    vector<int> ans = twoSum(nums, 6);
    for(int i=0;i<ans.size();i++){
        cout << ans[i] << ", ";
    }
    return 0;
}